package com.zhuchaooasystem.ui.home.fragment;

import android.text.TextUtils;
import android.widget.TextView;

import com.zhuchaooasystem.R;
import com.zhuchaooasystem.base.BaseFragment;
import com.zhuchaooasystem.entity.UserInfo;
import com.zhuchaooasystem.presenter.home.fragment.MineContract;
import com.zhuchaooasystem.presenter.home.fragment.MinePresenter;

import butterknife.BindView;

/**
 * @author yinsi
 */

public class MineFragment extends BaseFragment<MinePresenter> implements MineContract.View {

    @BindView(R.id.frag_mine_txt_name)
    TextView txt_name;
    @BindView(R.id.frag_mine_txt_phone)
    TextView txt_phone;
    @BindView(R.id.frag_mine_txt_position)
    TextView txt_position;
    @BindView(R.id.frag_mine_txt_department)
    TextView txt_department;

    private UserInfo user;

    @Override
    protected MinePresenter getPresenter() {
        return new MinePresenter(mContext, this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_mine;
    }

    @Override
    protected void initVariables() {
        user = UserInfo.getInstance();
    }

    @Override
    protected void initView() {
        txt_name.setText(user.getUserName());
        if (!TextUtils.isEmpty(user.getUserPhone()) && user.getUserPhone().length() == 11) {
            txt_phone.setText(user.getUserPhone().substring(0, 3) + "****" + user.getUserPhone().substring(7));
        }
        txt_position.setText(user.getUserPostion());
        txt_department.setText(user.getUserDeparet());
    }

    @Override
    protected void initDataAndLoadData() {
    }
}
